//
//  MineHeaderView.m
//  Rail
//
//  Created by hychen on 2018/2/25.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "MineHeaderView.h"

@interface MineHeaderView ()
@property (weak, nonatomic) IBOutlet UIImageView *avatarView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *descLabel;
@property (weak, nonatomic) IBOutlet UIButton *settingButton;

@end

@implementation MineHeaderView

+ (instancetype)headerView
{
    return [[[NSBundle mainBundle] loadNibNamed:@"MineHeaderView" owner:self options:nil] lastObject];
}

- (void)awakeFromNib
{
    [super awakeFromNib];
    self.avatarView.layer.cornerRadius = 50.f;
    self.avatarView.layer.masksToBounds = YES;
}

- (IBAction)settingButtonClick
{
    if (self.BlockClickSetting) {
        self.BlockClickSetting();
    }
}

- (IBAction)userInfoButtonClick:(id)sender {
    if (self.BlockClickUserInfo) {
        self.BlockClickUserInfo();
    }
}

- (void)setUserInfoModel:(UserInfoModel *)userInfoModel
{
    _userInfoModel = userInfoModel;
    
    [self.avatarView sd_setImageWithURL:[NSURL URLWithString:userInfoModel.logo_url] placeholderImage:ImageNamed_bb(@"me_default_portrait_img")];
    
    self.nameLabel.text = userInfoModel.username;
    self.descLabel.text = userInfoModel.sp_info.sp_name;
}
@end
